<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<div class="modal-dialog x-modal-dialog" style="width: 650px; margin-top: 100px;">

  <div class="modal-content">

    <div class="modal-header x-breadcrumb no-bottom-border clearfix">
      <h2><i class="glyphicon glyphicon-fire" title="访客记录"></i>&nbsp;&nbsp;<span>访客记录列表&nbsp;-&nbsp;修改访客记录</span></h2>
      <button type="button" class="close" data-dismiss="modal">&times;</button>
    </div>
    
    <form class="form-horizontal" method="POST" action="${ctx.host}/visitor-records/${visitorRecord.id}" data-validate="true">
    
      <input type="hidden" name="_method" value="PATCH">
      <input type="hidden" name="id" value="${visitorRecord.id}" />

      <div class="modal-body">

        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label">首次需求</label>
          <div class="col-xs-6 pull-left">
            <select name="demand" class="select2 form-control" data-validate="required">
              <option value=""></option>
              <option value="减脂塑形" ${visitorRecord.demand eq '减脂塑形' ? 'selected' : ''}>减脂塑形</option>
              <option value="增肌" ${visitorRecord.demand eq '增肌' ? 'selected' : ''}>增肌</option>
              <option value="体态" ${visitorRecord.demand eq '体态' ? 'selected' : ''}>体态</option>
              <option value="备孕" ${visitorRecord.demand eq '备孕' ? 'selected' : ''}>备孕</option>
              <option value="健康" ${visitorRecord.demand eq '健康' ? 'selected' : ''}>健康</option>
              <option value="减压" ${visitorRecord.demand eq '减压' ? 'selected' : ''}>减压</option>
              <option value="减重" ${visitorRecord.demand eq '减重' ? 'selected' : ''}>减重</option>
              <option value="学习" ${visitorRecord.demand eq '学习' ? 'selected' : ''}>学习</option>
              <option value="其他" ${visitorRecord.demand eq '其他' ? 'selected' : ''}>其他</option>
            </select>
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label">首次接触时间</label>
          <div class="col-xs-6">
            <input type="text" class="form-control date" name="occurDate" value="${visitorRecord.occurDate}" data-validate="required" placeholder="请选择时间"/>
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label">学员来访渠道</label>
          <div class="col-xs-6 pull-left">
            <select name="visitChannel" class="select2 form-control" data-validate="required">
              <option value=""></option>
              <c:forEach var="visitChannel" items="${enums['visitChannel']}">
                <option value="${visitChannel}" ${visitorRecord.visitChannel eq visitChannel ? 'selected' : ''}>${visitChannel.description}</option>
              </c:forEach>
            </select>
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label">首次接待人</label>
          <div class="col-xs-6 pull-left">
            <select name="receiver" class="select2 form-control" data-validate="required">
              <option value=""></option>
              <c:forEach var="staff" items="${persist.staff(currentPrincipal.id)}">
                <option value="${staff.id}" ${visitorRecord.receiver.id == staff.id ? 'selected' : ''}>${staff.name}</option>
              </c:forEach>
            </select>
          </div>
        </div>
        
        <!-- <div class="form-group x-form-group">
          <label class="col-xs-4 control-label">操作人</label>
          <div class="col-xs-6 pull-left">
             <select name="principal" class="select2 form-control" data-validate="required">
              <option value=""></option>
              <c:forEach var="staff" items="${empty currentPrincipal.site ? persist.siteStaff(0) : persist.siteStaff(currentPrincipal.site.id)}">
                <option value="${staff.id}" ${visitorRecord.principal.id == staff.id ? 'selected' : ''}>${staff.name}</option>
              </c:forEach>
            </select>
          </div>
        </div> -->
        
      </div>

      <div class="modal-footer">
        <button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">取消</button>
      </div>

    </form>

  </div>
  

</div>

<script type="text/javascript">
  $(function() {

    $('select[name="demand"]').select2({
      placeholder: '请选择首次需求',
      minimumResultsForSearch: Infinity,
      allowClear: true,
      width: '100%'
    });

    $('.date').datetimepicker({
      format: 'yyyy-mm-dd',
      autoclose: true,
      language: 'zh-CN',
      todayBtn: 'linked',
      todayHighlight: true,
      pickerPosition: 'bottom-right',
      minView: '2'
    });

    $('select[name="visitChannel"]').select2({
      placeholder: '请选择来访渠道',
      minimumResultsForSearch: Infinity,
      allowClear: true,
      width: '100%'
    });

    $('select[name="receiver"]').select2({
      placeholder : '请选择首次接待人',
      minimumResultsForSearch : Infinity,
      allowClear : true,
      width: '100%'
    });
    
    /*$('select[name="principal"]').select2({
      placeholder : '请选择操作人',
      minimumResultsForSearch : -1,
      allowClear : true,
      width: '100%'
    });*/

  })
</script>